<template>
  <div>
    <h1>我的新闻</h1>
      <el-col
        :span="20"
        v-for="(a,index) in news"
        :key="a.id"
        :offset="index =0"
      >
        <el-card :body-style="{ padding: '0px' }">
          <div class="left">
            <el-image
              style="width: 150px; height: 150px"
              :src="'http://120.77.71.211:9090/mynewsweb/'+a.path"
              class="image"
              fist="fill">
            </el-image>
          </div>

          <div style="padding: 14px">
            <div class="con">
              <a :href="'#/showMyNews?id='+a.id"><h1>{{a.title}}</h1></a><br>
              <a>{{a.summary}}</a>
              <div class="bottom clearfix">
                <span class="left">{{a.writer}}</span>
                <span class="right">{{a.time}}</span>
              </div>
            </div>
          </div>
        </el-card>
      </el-col>
  </div>
</template>

<script>
export default {
    name:"Comments",
    data() {
        return {
            user: {
                        userId:"",
                    },//用来存放用户登录信息
            news:[]
        }

    },
    // 生命周期
    created(){
        var userString = localStorage.getItem("user");
        this.user = JSON.parse(userString);
        //获取评论过的新闻
        var userId=this.user.userId;
        var _this=this;
        this.$axios.get("http://120.77.71.211:9090/mynewsweb/api/findNewByuserId?userId="+userId).then((res) => {
            _this.news=res.data;
        });
    }
}
</script>

<style>

</style>